var debug = true;
var $ = require("jquery");
require("jquery.cookie");
var model = require('../model/user.js');
var base = require("../base.js");

$.removeCookie('sessionid');



$.removeCookie('user');
$("#form-signin").submit(function(event) {
	event.preventDefault();
	var username = $('input[name="username"]').val();
	var password = $('input[name="password"]').val();
	model.login(username, password, function(data, error) {
		if (data.status == 200) {
			$.cookie("sessionid", data.data.sessionid);
			location.href = "index.html";
		} else {
			debug && console.log(data);
			alert(data.message);
		}

	});
});
